import * as way from "../../config/pay-way";
import componentsMaps from "../../config/components";
import initLinkedList from "../../utils/settings/initLinkedList";
export default {
    namespaced: true,
    state: {
        originPath: "",
        currentPath: "",
        gwtest: 0,
        payWay: [],
        loadingState: 0,
        //定义虚拟页面名称
        virtualPageName: "",
        //新增页面的信息
        addPageType: "",
        //新增页面的名称
        addPageTitle: "",
        addPages: [],
        specialTemplateParams: {},
        needUploadSpecialTemplate: false,//是否需要上传用来记录自定义页面的模板
        specialTemplate: {},
        paymentId: "",//支付方式id,
        realComponentsList: [],
        styleComponentsList: [],
        editComponentsList: [],
        fileArray: {},//Android-RN端上传图片的数组
    },
    getters: {
        getExitWebviewState: state => {
            console.log("state.originPath", state.originPath);
            console.log("state.currentPath", state.currentPath);
            return (state.originPath === state.currentPath || !state.originPath);
        },
        getGwTest: state => state.gwtest,
        //获取支付方式
        getPayWay: state => state.payWay,
        //获取loading显示状态
        getLoadingState: state => state.loadingState,
        //获取活动组件的自定义页面路径
        //获取虚拟页面名称
        getVirtualPageName: state => state.virtualPageName,
        //获取新增页面的信息
        getAddPageType: state => state.addPageType,
        //获取新增页面的名称
        getAddPageTitle: state => state.addPageTitle,
        getAddPages: state => state.getAddPages,
        getSpecialTemplateParams: state => state.specialTemplateParams,
        getNeedUploadSpecialTemplate: state => state.needUploadSpecialTemplate,
        //获取支付方式Id
        getPaymentId: state => state.paymentId,
        //获取当前页面的componentsList
        getRealComponentsList: state => state.realComponentsList,
        getStyleComponentsList: () => {
            return componentsMaps.style;
        },
        getEditComponentsList: state => state.editComponentsList,
        getSpecialTemplate: state => state.specialTemplate,//获取解析后的特殊模板的数据
        getFileArray: state => state.fileArray,
    },
    mutations: {
        //设置当前路径
        setCurrentPath(state, path) {
            console.log("设置当前路径", path);
            state.currentPath = path;
        },
        //设置原始路径
        setOriginPath(state, path) {
            state.originPath = path;
        },
        setGwTest(state) {
            state.gwtest = state.gwtest + 1;
        },
        //改变支付方式
        setPayWay(state, value) {
            
            state.payWay = value;
        },
        setLoadingState(state, value) {
            state.loadingState = value;
        },
        //设置虚拟页面的名称
        setVirtualPageName(state, value) {
            state.virtualPageName = value;
        },
        //设置新增页面的类型（=路径）
        setAddPageType(state, val) {
            state.addPageType = val;
        },
        //设置新增页面的名称（title）
        setAddPageTitle(state, val) {
            state.addPageTitle = val
        },
        setAddPages(state, arr) {
            state.addPages = arr;
        },
        setSpecialTemplateParams(state, obj) {
            state.specialTemplateParams = obj;
        },
        setNeedUploadSpecialTemplate(state, flag) {
            state.needUploadSpecialTemplate = flag;
        },
        //改变支付方式的id
        setPaymentId(state, id) {
            state.paymentId = id;
        },
        //设置当前页面的componentsList
        setRealComponentsList(state, list) {
            state.realComponentsList = list;
        },
        //设置当前页面的styleComponentsList
        setStyleComponentsList(state, list) {
            // console.log("list-->", list);
            state.styleComponentsList = list;
        },
        setEditComponentsList(state, list) {
            state.editComponentsList = list;
        },
        //设置解析之后的特殊模板的数据
        setSpecialTemplate(state, obj) {
            state.specialTemplate = obj;
        },
        setFileArray(state, obj) {
            console.log("设置fileArray", obj);
            state.fileArray = Object.assign({}, state.fileArray, obj);
        }
    }
}